package com.demonzym.activity;

import io.vov.vitamio.MediaPlayer;
import io.vov.vitamio.widget.MediaController;
import io.vov.vitamio.widget.VideoView;
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.Window;

import com.demonzym.videoplayer.R;

public class VideoPlayerActivity extends Activity {

	private VideoView mVideoView;
	
	private String mVideoUrl;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
        requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		setContentView(R.layout.videoview);
		
		if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
			return;

		iniData();
		
		setContentView(R.layout.videoview);
		mVideoView = (VideoView) findViewById(R.id.surface_view);
		mVideoView.setVideoPath(mVideoUrl);
		mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
		mVideoView.setMediaController(new MediaController(this));

		overridePendingTransition(R.anim.activity_open_enter, R.anim.tv_off);
	}

	private void iniData() {
		mVideoUrl = getIntent().getAction().trim();
	}
	
	public void onConfigurationChanged(Configuration newConfig) {
		if (mVideoView != null)
			mVideoView.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
		super.onConfigurationChanged(newConfig);

	};
}
